package com.automobile.dao;

import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.automobile.domain.Orderform;

@CacheNamespace(blocking = true)
@Repository
public interface OrderformDao {
	
	@Select("select * from orderform where userid = #{userId}")
	List<Orderform> findOrderformByUserId(int userId);//根据用戶id找用戶的订单
	
	@Select("select * from orderform where merchantId = #{merchantId}")
	List<Orderform> findOrderformByMerchantId(int merchantId);//根据卖家id找卖家订单
	
	@Select("select * from orderform where id = #{orderformId}")
	Orderform findOrderformById(int orderformId);//找到指定Id的orderform
	
	@Insert(" insert into orderform(userId,address,money,merchantId)"
			+ "values(#{userId},#{address},#{money},#{merchantId})")
	void save(Orderform orderform);//保存
	
	@Update("update orderform set address = #{address} , money = #{money} where id = #{id}")
	void update(Orderform orderform);//更新
	
	@Delete("delete from orderform where id = #{id}")
	void delete(int id);//删除
	
}
